<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="com.hz.control.ParamDepartmentManager"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.hz.model.ParamDepartment"%>
<%@page import="java.util.Collection"%>
<%@page import="com.hz.model.Hobby"%>
<%@page import="com.hz.control.HobbyControl"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.hz.model.Province"%>
<%@page import="java.util.List"%>
<%@page import="com.hz.util.GradeList"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>注册</title>
</head>
	<link href="../../resources/register/css/formitem.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../resources/register/jquery-1.4.2.min.js"></script>
	<script type="text/javascript" src="../../resources/register/jquery.form-1.0.1.js"></script>
	<script type="text/javascript" src="../../resources/register/jquery.form.valid-1.0.1.js"></script>
<script type="text/javascript" src="../common/js/calendar.js"></script>
<script type="text/javascript" src="../common/js/getMajors.js"></script>
<script language=javascript>
 function getCheckbox(checkboxname)
 { 
  var obj=document.getElementsByName(checkboxname);
  var strsel = "";
  for (var i=0;i<=obj.length-1;i++)
  {
     if (obj[i].checked)
     {
    strsel = "@"+strsel + obj[i].value+"@";
     }
  }
  //alert(strsel)
  document.getElementById("setValue").value=strsel;//将选中的值赋给hidden
  //alert(document.getElementById("setValue").value);
  //return false;
  var form = document.getElementById("testform");
 if(submitValid()){
	 //alert("dd");
     form.submit();
	 }
  }
</script>
<script type="text/javascript">
		$(function(){//跟顺序有关！按照form里面显示顺序排
			$("#username").username();
			$("#realName").chineseName();
			$("#password").password();
			$("#confirmpwd").confirmpwd();
			$("#stuNum").number();
			$("#idcard").idcard();
			$("#mobile").mobile();
			$("#qq").qq();
			$("#email").email();
			$("#grade").commonSelect();
			$("#departmentId").commonSelect();
			$("#htmlsave").htmlform();
			$("#ajaxsave").ajaxform();
			$("form").find("input[type!='radio'][type!='checkbox'][type!='button'][type!='submit'][type!='reset']").each(function(){
				$(this).addClass("form_item_input");
			});
		});
	</script>
<body>
<%
			request.setCharacterEncoding("utf-8");
			//System.out.println("-------"+Picurl);
		%>
<form action="register_do.jsp" method="post" name="form" id="testform">
<div class='init'>
<table  class="formtable">

   <tr>
				<th>
					<label class="form-item-title">用户名：</label>
				</th>
				<td>
				<input name="picPath" type="hidden" size="5" value="1.jpg" />
					<input id="username" name="username"type="text" required="true"  valid='username'/>
				</td>
				<th>
					<label class="form-item-title">真实姓名：&nbsp;&nbsp;</label>
				</th>
				<td>
					<input id="realName"  name="realName" required="true"  type="text" valid='chineseName'/>
				</td>
			</tr>
			<tr>
				<th>
					<label class="form-item-title">密码：</label>
				</th>
				<td>
					<input type="password" id="password" required="true" valid='password' name="password1"/>
				</td>
				<th>
					<label class="form-item-title">确认密码：</label>
				</th>
				<td>
					<input type="password" id="confirmpwd" required="true"valid='confirmpwd' name="password2"/>
				</td>
			</tr><tr>
				<th>
					<label class="form-item-title">学号：</label>
				</th>
				<td>
					<input type="text" name="stuNum" id="stuNum" required="true" valid='number'  />
				</td>
				<th>
					<label class="form-item-title"> 身份证号：</label>
				</th>
				<td>
					<input type="text" id="idcard"  size="30" maxlength="19" valid='idcard'  name="idCard" required="true" />
				</td>
			</tr><tr>
				<th>
					<label class="form-item-title">性别：&nbsp;&nbsp;</label>
				</th>
				<td>
					男<input type="radio" id="male" name="sex" value="1" checked>
					女<input type="radio" id="female" name="sex" value="0"> 
				</td>
				<th>
					<label class="form-item-title"> 联系电话：</label>
				</th>
				<td>
					<input type="text"  name="tel"  id="mobile"  required="true"  valid='mobile' />
				</td>
			 </tr><tr>
              <th><label class="form-item-title"> QQ：&nbsp;&nbsp;</label></th>
              <td><input type="text" name="qq" valid='qq'  id="qq"/></td>
				<th>
					<label class="form-item-title"> Email：&nbsp;&nbsp;</label>
				</th>
				<td>
					<input type="text" id="email" valid='email'  name="email"></input>
				</td>
			</tr><tr>
             <th><label class="form-item-title">学历：&nbsp;&nbsp;</label></th>
             <td><input type="radio" name="stuLevel" value="0" checked/>本科生
                     <input type="radio" name="stuLevel" value="1"/>研究生</td>
                     <th><label class="form-item-title">年级：</label></th>
            <td><select name="grade" id="grade" valid="commonSelect"  required="true">
                <%
                     int grade[] = GradeList.getGradeList();
                     for(int g:grade){
                %>
                <option value="<%=g %>" ><%=g%></option>
                <%} %>
                </select></td>
             
            </tr><tr>
            <th><label class="form-item-title">学院：</label></th>
             <td><select name="departmentId" id="departmentId" valid="commonSelect"  required="true">
                <option value="">-选择学院-</option>
             <% 
                  ArrayList<ParamDepartment> pd = ParamDepartmentManager.getAllDepartment(0);
                  for(int i=0;i<pd.size();i++){
                      ParamDepartment p = pd.get(i);  
             %>
              <option value="<%=p.getId() %>"><%=p.getDepartmentName() %></option>
             <%} %>
            </select></td>
            <th><label class="form-item-title">专业：&nbsp;&nbsp;</label></th>
            <td><select name="majorId" id="majorId"></select></td>
            
               </tr><tr>
               <th><label class="form-item-title"> 出生日期&nbsp;&nbsp;&nbsp;&nbsp;</label></th>
               <td><input name="birthday"type="text" id="range_date" onclick="new Calendar(1980, 2020).show(this);"  size="10" maxlength="10" readonly="readonly"></td>
              <th><label class="form-item-title">籍贯&nbsp;&nbsp;&nbsp;&nbsp;</label></th>
             <td><select name="birthPlace">
                  <option value="">-选择省份-</option>
                 <%  String provinces[]=Province.getAllProvinces();
                     for (String p : provinces) {
                 %>
                   <option value="<%=p%>"><%=p%></option>
                 <%} %>
               </select></td>
               </tr><tr>
               <th><label class="form-item-title">志愿者服务类型&nbsp;&nbsp;&nbsp;&nbsp;</label></th>
               <td>
            <%
                 Collection<Hobby> hs = HobbyControl.getAllHobbies();
                 Iterator<Hobby> it = hs.iterator();
                 while(it.hasNext()){
                      Hobby h=it.next();
              %>
            <input type="checkbox" name="hobbies" value="<%=h.getId()%>"><%=h.getHobbyName() %>
             <%} %>
             <input type="hidden" id="setValue" name="hobby">
            </td>
            </tr><tr>
            <th><label class="form-item-title"> 志愿者经历&nbsp;&nbsp;&nbsp;&nbsp;</label></th>
            <td><textarea class='text' name="volunteerExp"></textarea></td>
            <th><label class="form-item-title"> 曾获校级以上荣誉&nbsp;&nbsp;&nbsp;&nbsp;</label></th>
            <td><textarea class='text' name="award"></textarea></td>
            </tr>             
           </table>
           <p class='pap'><input class='btn br3' type="button"   onclick="getCheckbox('hobbies')" value="提交" >&nbsp;&nbsp;&nbsp;&nbsp;<input class='btn br3' type="reset" value="重置"></p>
           </div>
</form>
</body>
</html>